/*
 *  Sample C -- header file for symbol table 
 */
#ifndef __SYMBOL_H
#define __SYMBOL_H
#include <stdio.h>
#include <stdlib.h>

typedef struct symtab {
  char * name;                    /* name pointer */
  int kind;                       /* symbol type */
  int blockLevel;                 /* static block depth */
  union {
    int num;                      /* parameter number */
    struct symtab * link;         /* parameter link */
  } S;
  struct symtab * type;           /* type link */
  int offset;                     /* symbolic definitions */
  struct symtab * next;           /* next entry */
} WORD;

typedef WORD * WORDPTR;

#define NOTSET (-1)               /* no count yet set */

/*
 *  kinds values
 */

#define UDEC  0                   /* not declared */
#define FUNC  1                   /* fuction */
#define UFUNC 2                   /* undefined function */
#define VAR   3                   /* declared variable */
#define TYPE  5                   /* declared type */
#define PARAM 4                   /* undeclared parameter */


/* 
 * typed functions, symbol table module
 */

void move(WORDPTR symbol);
WORDPTR lookUp(char *s);
 
WORDPTR linkParam();              /* chain parameters */
WORDPTR find();                   /* locate symbol by name */
WORDPTR makeParam();              /* declare parameter */
WORDPTR makeVar();                /* define variable */
WORDPTR makeFunc();               /* define function */
void addType();                   /* assign type */
void blockPush();
void blockPop();
void checkVar( WORDPTR symbol);
void checkFunc( WORDPTR symbol);
void checkParam( WORDPTR symbol, int count);
WORDPTR checkType( WORDPTR type1, WORDPTR type2);
WORDPTR getType( WORDPTR symbol);

#endif

